{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Experiments with CDF, iCDF and other stat stuff to apply it to QuantilleRegression code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pylab as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Normal distribution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy.stats import norm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.arange(-10, 10, 0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "c = norm.cdf(x, loc=3, scale=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEICAYAAACktLTqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3XmYXHWd7/H3t9csnX1f6QSSkLCZ\n0ARQUGRRiEocN4JXReQZrguOXh3vgPgwXNT7uFy9bjiIy2VgBgFRMI5hkFVUTMxKukMS0mmSXhKS\nTm9ZOt2d7v7eP+qEKTpV6epOVZ+qU5/X89TTVef8zqlvnar+1Knf2czdERGRaCkIuwAREUk/hbuI\nSAQp3EVEIkjhLiISQQp3EZEIUriLiESQwl1ympl9zcwOmNlrYdcyEGZWbmZuZkUptr/PzL4W3L/U\nzLZntkLJdQ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eCm4bSHW\nNTEUy+8BoBLYHHywpvWtLXi8jNjeGDuHorbg/agDNgW3e/rWNZTLLNHrB+4i9uUDMCz4/FQHn6e5\nQ7CMLiHWnbY5bjktAz55/LMG3BIsm5eIbZh+8xB9rhK+N31qM+DuYJlWEre3W4ZrG0ksrMfEDRvy\nZUbsy2UvcCzIsJuIbad5BtjYCK9tAAAASUlEQVQBPA2MD9pWAD+Lm/YTwWetGrjxVOrQ6QdERCIo\nF7tlRESkHwp3EZEIUriLiESQwl1EJIIU7iIiEaRwFxGJIIW7iEgE/X/0rSB6fO57ogAAAABJRU5E\nrkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fbd7e993ef0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x, c)\n",
    "plt.title(\"CDF of normal distr\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "ic = norm.ppf(c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEICAYAAABbOlNNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAH9pJREFUeJzt3Xt4HXd95/H3x5YlWTdbtmTL19gm\nTgK5OUFxkqc0QBIgZGkCJYXQBwosXQNbti2ltLTsUkrLtuFSdimU1EB2KQ8p4dKAS0wSUrINaUmI\nnObmXIjjxLHkm2RbsmTJkiV9948zUs6RJR3Z0hxZOp/X8+jRnJnfmfmNL/OZ+f1+M6OIwMzMbMic\n6a6AmZmdXhwMZmaWw8FgZmY5HAxmZpbDwWBmZjkcDGZmlsPBYGZmORwMNuNJekHS1dNdj8mQtFHS\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FXwhPc548AX5X0\nYTId0e+Z4Sd5SPpHMgFfl/Sd/BkwDyAibibTl3ItsAPoBt47pduf4X9+ZmY2xWZrU5KZmZ0iB4OZ\nmeVwMJiZWQ4Hg5mZ5XAwmJlZDgeDmZnlcDCYmVmO/w/qiG65ViwkYAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fbd7e996b38>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(c, ic)\n",
    "plt.title(\"Inverse CDF\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [],
   "source": [
    "d = c[1:] - c[:-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAEICAYAAABfz4NwAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3XucXXV97//Xe+6XJJPMJeQ2ySQk\nBAIVkBA4FRCLYlBq7ClIqEfpkZZ6NG09lvbgqVAOtb/zwz6qrQ9pPSgoclRAWjRqEPWgp2hLyAAJ\nJEBgkkzmktvcMsncb5/zx1o7bLZ7ZvYke/b183w85jFrr/Vd3/3Za/bsz17f73d9l8wM55xzriDd\nATjnnMsMnhCcc84BnhCcc86FPCE455wDPCE455wLeUJwzjkHeEJwDkl3S/rfMyhvklaHy1+RdGeS\n4lguqU9SYfj4F5L+IBl1h/U9KemWZNXnco8nBDfrJDVLOiapMmrdH0j6RRrDSgoz+7iZ/fV05cJj\n8O5p6moxszlmNn6mccVLcmZ2nZk9dKZ1u9zlCcGlSiHwp2daiQI5976VVJTuGJzLuX8sl7H+Frhd\n0vx4GyX9pq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cc84BnhCcc86F\nPCE455wDPCE455wLeUJwzjkHeEJwzjkX+n8KgXfMq3F0yQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fbd7ea675f8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x[1:], d)\n",
    "plt.title(\"Normal distribution\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Mean calculation from inverse CDF\n",
    "\n",
    "https://ckrao.wordpress.com/2012/07/18/the-mean-of-a-random-variable-in-terms-of-its-cdf/\n",
    "\n",
    "According to Fubini's theorem, mean equals to the area below cdf for the negative x minus the area above cdf for the positive x.\n",
    "\n",
    "In case of inverse CDF, it will be equal to the area above iCDF for negative X minus the area below iCDF for the positive X."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-13.000000000000002"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ic.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [],
   "source": [
    "def mean_from_icdf(probs, icdfs):\n",
    "    res = 0.0\n",
    "    prev_p = None\n",
    "    for x, p in zip(icdfs, probs):\n",
    "        if np.isinf(x):\n",
    "            continue\n",
    "        if prev_p is not None:\n",
    "            res += x * (p - prev_p)\n",
    "        prev_p = p\n",
    "    return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.0499999999737488"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mean_from_icdf(probs=c, icdfs=x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If percentille step is fixed, expected value will be equal to mean(icdf)*delta_p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
